package com.huike.web.controller.report;


import com.huike.common.utils.DateUtils;
import com.huike.report.domain.vo.IndexTodayInfoVO;
import com.huike.report.domain.vo.IndexTodoInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页--今日简报--数据展示
     *
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
        //获取当前时间(格式为yyyy-MM-dd)
        String todayDate = DateUtils.getDate();
        //可以将todayDate时间转换为任意时间来调试
        IndexTodayInfoVO indexTodayInfoVO = reportService.getTodayInfo(todayDate);
        return AjaxResult.success(indexTodayInfoVO);
    }

    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginTime, @RequestParam("endCreateTime") String endTime) {
        IndexTodoInfoVO indexTodoInfoVO = reportService.getTodoInfo(beginTime,endTime);
        return AjaxResult.success(indexTodoInfoVO);
    }

}